package cn.graydove.bot.repository;

import cn.graydove.bot.model.entity.QqGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface GroupRepository extends JpaRepository<QqGroup, Integer> {

    Optional<QqGroup> findByGroupNumber(Long groupNumber);

    Boolean existsByGroupNumber(Long groupNumber);

    @Query("select g.alive from QqGroup g where g.groupNumber=?1")
    Boolean isOpen(Long groupNumber);

    @Query("select g.attacker from QqGroup g where g.groupNumber=?1")
    Long isAttacking(Long groupNumber);

}
